const { app, BrowserWindow } = require("electron");

const createWindow = () => {
  const win = new BrowserWindow({
    width: 800,
    height: 600
  });

  win.loadFile("index.html");
  // win.webContents.openDevTools();
  return win;
};

const createAnotherWindow = (parent) => {
  const win = new BrowserWindow({
    width: 600,
    height: 300,
    parent
  });
  win.loadFile("second.html");
};

app.whenReady().then(() => {
  const parent = createWindow();
  createAnotherWindow(parent);
  // console.log(process);

  app.on("activate", () => {
    if (BrowserWindow.getAllWindows().length === 0) {
      createWindow();
    }
  });
});

app.on("window-all-closed", () => {
  if (process.platform !== "darwin") {
    app.quit();
  }
});
